package com.ss.android.article.base.ui;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.account.c.QZone;
import com.ss.android.article.browser.R;
import com.ss.android.article.common.share.entry.Action;
import com.ss.android.article.share.c.a;
import com.ss.android.article.share.e.b;
import com.ss.android.article.share.entity.ShareAction;
import com.ss.android.article.share.ui.RecyclerViewWrapper;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.newmedia.BaseAppData;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;

import org.json.JSONObject;

public class BaseActionDialog extends a implements b {
    public enum CtrlFlag {
        hasFavor,
        hasWeixin,
        hasHtmlShare,
        hasReport,
        hasDisplaySetting,
        disableAlipay,
        hasAskBanComment,
        hasAskAllowComment,
        hasAskDeleteAnswer,
        disableWeiBo,
        disableTencent,
        hasDingDing
    }

    public enum DisplayMode {
        DETAIL_MENU,
        SHARE,
        PGC_SHARE,
        SHARE_VIDEO_DETAIL,
        DETAIL_ALL,
        VIDEO_MORE,
        VIDEO_MORE_NO_PGC,
        POST_MENU,
        POST_SHARE,
        FORUM_SHARE,
        VIDEO_MORE_WITH_DIGG,
        VIDEO_SUBJECT,
        UPDATE_SHARE,
        CONCERN_SHARE,
        ANSWER_SHARE,
        ANSWER_LIST_SHARE,
        LIVE_CHAT_SHARE,
        VOLCANO_LIVE_SHARE,
        QUESTION_ACTION
    }


    private boolean A;
    private DisplayMode B;
    private EnumSet C;
    private boolean D;
    private boolean E;
    private boolean F;
    private boolean G;
    private boolean H;
    private boolean I;
    private boolean J;
    private boolean K;
    private boolean L;
    private int a;
    public long b;
    public long c;
    public long d;
    public long e;
    public JSONObject f;
    private String z;

    public BaseActionDialog(Activity arg3, b arg4, int arg5, String arg6, DisplayMode arg7, EnumSet arg8) {
        super(arg3);
        this.A = false;
        this.B = DisplayMode.SHARE;
        new g(this);
        this.F = QZone.a(((Context) arg3));
        this.G = QZone.b(((Context) arg3));
        this.mActivity = arg3;
        this.mResources = this.mActivity.getResources();
        this.u = arg4;
        this.a = arg5;
        this.z = arg6;
        this.B = arg7;
        ShareAction.text.textId = R.string.c1;
        Action.report.textId = R.string.cf;
        this.C = arg8;
        if (arg8 != null) {
            arg8.contains(CtrlFlag.hasWeixin);
            this.D = arg8.contains(CtrlFlag.hasHtmlShare);
            this.E = arg8.contains(CtrlFlag.hasReport);
            arg8.contains(CtrlFlag.disableAlipay);
            this.I = arg8.contains(CtrlFlag.hasAskAllowComment);
            this.H = arg8.contains(CtrlFlag.hasAskBanComment);
            this.J = arg8.contains(CtrlFlag.hasAskDeleteAnswer);
            this.L = arg8.contains(CtrlFlag.disableTencent);
            this.K = arg8.contains(CtrlFlag.disableWeiBo);
        }
    }

    public final List<com.ss.android.article.share.entity.a> a(List<com.ss.android.article.share.e.a> arg12) {
        ArrayList v0_1 = null;
        int v2;
        int v10 = 5;
        int v9 = 4;
        int v8 = 3;
        if (arg12 == null || (arg12.isEmpty())) {
            v0_1 = null;
        } else {
            ArrayList v1 = new ArrayList();
            Iterator v5 = arg12.iterator();
            while (v5.hasNext()) {
                Object v0 = v5.next();
                int v6 = ((com.ss.android.article.share.e.a) v0).getItemId();
                if (v6 >= 0) {
                    if (!Action.hasAction(v6) && !ShareAction.hasAction(v6)) {
                        v2 = 0;
//                        goto label_22;
                    } else if (this.C != null && (this.C.contains(CtrlFlag.hasDisplaySetting)) && v6 == 15) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.D && v6 == 11) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.E && v6 == 16) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.H && v6 == 21) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.I && v6 == 22) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.J && v6 == 23) {
                        v2 = 0;
//                        goto label_23;
                    } else if ((this.L) && v6 == 6) {
                        v2 = 0;
//                        goto label_23;
                    } else if ((this.K) && v6 == v10) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.F && v6 == v8) {
                        v2 = 0;
//                        goto label_23;
                    } else if (!this.G && v6 == v9) {
                        v2 = 0;
//                        goto label_23;
                    } else if (v6 == 18) {
                        v2 = 0;
//                        goto label_23;
                    } else if (v6 == 19) {
                        v2 = 0;
//                        goto label_23;
                    } else if (v6 == 24) {
                        v2 = 0;
//                        goto label_23;
                    } else if (this.a == 201 && (v6 == 14 || v6 == 11)) {
                        v2 = 0;
//                        goto label_23;
                    } else if ((this.a == 202 || this.a == 203 || this.a == 204 || this.a == 209 || this.a == 210) && (v6 != 2 && v6 != 1 && v6 != v8 && v6 != v9 && v6 != 0 && v6 != v10 && v6 != 24)) {
                        v2 = 0;
//                        goto label_23;
                    } else if (this.a != 207 && this.a != 203 && this.a != 204 && v6 == 0) {
                        v2 = 0;
//                        goto label_23;
                    } else if (v6 == 12 && this.x == null) {
                        v2 = 0;
//                        goto label_23;
                    } else {
                        v2 = 1;
                    }
                } else {
                    label_22:
                    v2 = 0;
                }

                label_23:
                if (v2 == 0) {
                    continue;
                }

                com.ss.android.article.share.entity.a v2_1 = new com.ss.android.article.share.entity.a();
                v2_1.e = v6;
                v2_1.a = ((com.ss.android.article.share.e.a) v0).getIconId();
                v2_1.b = ((com.ss.android.article.share.e.a) v0).getTextId();
                v2_1.f = false;
                v2_1.g = null;
                switch (v6) {
                    case 12: {
                        v2_1.g = this.x;
                        v2_1.c = this.x.c;
                        break;
                    }
                    case 13: {
                        if (this.C == null) {
                            break;
                        } else if (!this.C.contains(CtrlFlag.hasFavor)) {
                            break;
                        } else {
                            v2_1.b = R.string.c6;
                            v2_1.f = true;
                            break;
                        }
                    }
                }

                label_35:
                ((List) v1).add(v2_1);
            }

            v0_1 = v1;
        }

        return ((List) v0_1);
    }

    public void a() {
        int v8 = 8;
        int v7 = 4;
        boolean v1 = false;
        this.d();
        List v4 = this.a(this.r);
        this.a(this.g, v4, false, false);
        List v5 = this.a(this.s);
        RecyclerViewWrapper v6 = this.h;
        boolean v3 = v4 == null || v4.size() <= v7 ? false : true;
        boolean v0 = v4 == null || (v4.isEmpty()) ? true : false;
        this.a(v6, v5, v3, v0);
        List v3_1 = this.a((List<com.ss.android.article.share.e.a>) null);
        v6 = this.i;
        v0 = v4 == null || v4.size() <= v7 || v5 == null || v5.size() <= v7 ? false : true;
        if (v4 == null || (v4.isEmpty()) || v5 == null || (v5.isEmpty())) {
            v1 = true;
        }

        this.a(v6, v3_1, v0, v1);
        if (v4 == null || (v4.isEmpty()) || v5 == null || (v5.isEmpty())) {
            UIUtils.setVisibility(this.n, v8);
        }

        if (v5 == null || (v5.isEmpty()) || v3_1 == null || (v3_1.isEmpty())) {
            UIUtils.setVisibility(this.o, v8);
        }
    }

    public final void a(RecyclerViewWrapper arg7, List arg8, boolean arg9, boolean arg10) {
        int v1;
        int v4 = R.dimen.hj;
        int v3 = R.dimen.share_dialog_padding;
        if (arg7 != null) {
            if (arg8 != null && !arg8.isEmpty()) {
                arg7.setAdapter(new com.ss.android.article.share.a.a(this.mActivity, arg8, this, this.mAvatarLoader));
                int v0 = arg8.size();
                if (arg10) {
                    v1 = this.mResources.getDimensionPixelOffset(R.dimen.hk);
                    v0 = (this.w - this.mResources.getDimensionPixelOffset(v4) * v0 - (v0 - 1) * v1) / 2;
                } else {
                    v0 = (arg9) || arg8.size() > 4 ? (this.w - this.mResources.getDimensionPixelOffset(R.dimen.hm) - this.mResources.getDimensionPixelOffset(v3) - (this.mResources.getDimensionPixelOffset(v4) << 2)) / 4 : (this.w - (this.mResources.getDimensionPixelOffset(v3) << 1) - (this.mResources.getDimensionPixelOffset(v4) << 2)) / 3;
                    v1 = v0;
                    v0 = this.mResources.getDimensionPixelOffset(v3);
                }

                if (v1 <= 0) {
                    return;
                }

                if (v0 < 0) {
                    return;
                }

                com.ss.android.article.share.c.a.a$a v2 = new com.ss.android.article.share.c.a.a$a(v1, v0);
                if (arg7 == this.g) {
                    if (this.j != null) {
                        this.g.a(this.j);
                    }

                    this.j = (RecyclerViewWrapper.b) v2;
                } else {
                    if (arg7 == this.h) {
                        if (this.k != null) {
                            this.h.a(this.k);
                        }

                        this.k = ((com.ss.android.article.share.ui.RecyclerViewWrapper.b) v2);
//                        goto label_41;
                    } else if (arg7 != this.i) {
//                        goto label_41;
                    } else if (this.l != null) {
                        this.i.a(this.l);
                    } else {
                        this.l = ((com.ss.android.article.share.ui.RecyclerViewWrapper.b) v2);
                    }
                }

                label_41:
                arg7.b(((com.ss.android.article.share.ui.RecyclerViewWrapper.b) v2));
                return;
            }

            UIUtils.setVisibility(((View) arg7), 8);
        }
    }

    public final void a(String arg3, boolean arg4, String arg5) {
        this.x = new com.ss.android.article.share.entity.a();
        this.x.d = arg3;
        this.x.c = arg5;
        this.x.g = Boolean.valueOf(arg4);
    }

    public final void a(EnumSet arg8) {
        boolean v0 = false;
        this.C = arg8;
        if (arg8 != null) {
            arg8.contains(CtrlFlag.hasWeixin);
            this.D = arg8.contains(CtrlFlag.hasHtmlShare);
            this.E = arg8.contains(CtrlFlag.hasReport);
        }

        List v3 = this.a(this.r);
        List v4 = this.a(this.s);
        this.a((List<com.ss.android.article.share.e.a>) null);
        RecyclerViewWrapper v5 = this.h;
        boolean v2 = v3 == null || v3.size() <= 4 ? false : true;
        if (v3 == null || (v3.isEmpty())) {
            v0 = true;
        }

        this.a(v5, v4, v2, v0);
    }

    public boolean a(com.ss.android.article.share.entity.a arg4, View arg5, a arg6) {
        boolean v0;
        if (!this.g() || this.u == null) {
            v0 = false;
        } else {
            v0 = this.u.a(arg4, arg5, ((a) this));
            this.A = true;
            if (!this.y) {
                this.dismiss();
            }
        }

        this.y = false;
        return v0;
    }

    public int b() {
        return R.layout.base_action_dialog;
    }

    public void c() {
        if (this.g()) {
            this.dismiss();
        }
    }

    public void d() {
        com.ss.android.article.share.e.a[] v0;
        int v6 = 4;
        int v5 = 3;
        int v4 = 2;
        switch (com.ss.android.article.base.ui.h.a[this.B.ordinal()]) {
            case 1: {
                v0 = new com.ss.android.article.share.e.a[5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                v0[v5] = ShareAction.link;
                v0[v6] = ShareAction.text;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v4];
                v0[0] = Action.pgc;
                v0[1] = Action.report;
                this.s = Arrays.asList(((Object[]) v0));
                this.mCancleBtn.setText(com.ss.android.article.browser.R.string.k4);
                break;
            }
            case 2: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v6];
                v0[0] = Action.dislike;
                v0[1] = Action.favor;
                v0[v4] = Action.report;
                v0[v5] = ShareAction.copy_link;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 3: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v6];
                v0[0] = Action.favor;
                v0[1] = Action.dislike;
                v0[v4] = Action.report;
                v0[v5] = ShareAction.copy_link;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 4: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = Action.favor;
                v0[1] = ShareAction.copy_link;
                v0[v4] = Action.report;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 5: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v6];
                v0[0] = Action.pgc;
                v0[1] = Action.favor;
                v0[v4] = ShareAction.copy_link;
                v0[v5] = Action.report;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 6: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v4];
                v0[0] = ShareAction.link;
                v0[1] = ShareAction.text;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 7: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = Action.add_pgc_to_desktop;
                v0[1] = ShareAction.link;
                v0[v4] = ShareAction.text;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 8: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = Action.report;
                v0[1] = ShareAction.link;
                v0[v4] = ShareAction.text;
                this.s = Arrays.asList(((Object[]) v0));
                break;
            }
            case 9: {
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                this.r = Arrays.asList(((Object[]) v0));
                break;
            }
            case 10: {
                v0 = new com.ss.android.article.share.e.a[5];
                v0[0] = ShareAction.wxtimeline;
                v0[1] = ShareAction.wx;
                v0[v4] = ShareAction.qq;
                v0[v5] = ShareAction.link;
                v0[v6] = ShareAction.text;
                this.r = Arrays.asList(((Object[]) v0));
                v0 = new com.ss.android.article.share.e.a[v5];
                v0[0] = Action.pgc;
                v0[1] = Action.favor;
                v0[v4] = Action.report;
                this.s = Arrays.asList(((Object[]) v0));
                this.mCancleBtn.setText(com.ss.android.article.browser.R.string.k4);
                break;
            }
        }

        ArrayList v0_1 = new ArrayList();
        if (this.r != null && !this.r.isEmpty()) {
            ((List) v0_1).addAll(this.r);
        }

        if (this.s != null && !this.s.isEmpty()) {
            ((List) v0_1).addAll(this.s);
        }

        if (!((List) v0_1).isEmpty()) {
            this.r = ((List) v0_1);
        }

        this.s = null;
    }

    public void dismiss() {
        long v4;
        long v6 = 0;
        CallbackCenter.notifyCallback(BaseAppData.callbackTypePopUiShowStateChanged, new Object[]{Boolean.valueOf(false)});
        if (!this.A && this.mActivity != null && !android.support.design.a.isTextEmpty(this.z) && this.B != DisplayMode.VOLCANO_LIVE_SHARE) {
            Activity v1 = this.mActivity;
            String v2 = this.z;
            String v3 = "share_cancel_button";
            switch (this.a) {
                case 203:
                case 204: {
                    v4 = this.d;
                    break;
                }
                case 205: {
                    v4 = this.e;
                    break;
                }
                case 200:
                case 201:
                case 208: {
                    v4 = this.b;
                    break;
                }
                default: {
                    v4 = v6;
                    break;
                }
            }

            switch (this.a) {
                case 200:
                case 201:
                case 208: {
                    v6 = this.c;
                    break;
                }
            }

            MobClickCombiner.onEvent(((Context) v1), v2, v3, v4, v6, this.f);
        }

        if (this.mAvatarLoader != null) {
            this.mAvatarLoader.onDestroy();
        }

        if (this.mTaskInfo != null) {
            this.mTaskInfo.a = true;
        }

        super.dismiss();
    }

    public final void e() {
        this.y = true;
    }

    public final void f() {
        com.ss.android.j.b.isNightModeToggled();
    }

    public void show() {
        CallbackCenter.notifyCallback(BaseAppData.callbackTypePopUiShowStateChanged, new Object[]{Boolean.valueOf(true)});
        super.show();
    }
}

